package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.ClientEnquiryEntity;
import io.renren.modules.sys.service.ClientEnquiryService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * @author zyj
 * @email 740916741@qq.com
 * @date 2019-02-27 11:35:25
 */
@RestController
@RequestMapping("sys/clientenquiry")
public class ClientEnquiryController {
    @Autowired
    private ClientEnquiryService clientEnquiryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("clientenquiry:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = clientEnquiryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("clientenquiry:info")
    public R info(@PathVariable("id") Integer id){
			ClientEnquiryEntity clientEnquiry = clientEnquiryService.selectById(id);

        return R.ok().put("clientEnquiry", clientEnquiry);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("clientenquiry:save")
    public R save(@RequestBody ClientEnquiryEntity clientEnquiry){
            clientEnquiry.setCreateTime(new Date());
			clientEnquiryService.insert(clientEnquiry);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("clientenquiry:update")
    public R update(@RequestBody ClientEnquiryEntity clientEnquiry){
			clientEnquiryService.updateById(clientEnquiry);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("clientenquiry:delete")
    public R delete(@RequestBody Integer[] ids){
			clientEnquiryService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
